home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
tshell10.arc
/
TSHELL.DOC
< prev
Wrap
Text File
|
1987-03-14
|
8KB
|
243 lines
TSHELL
Turbo Pascal Preprocessor Shell
Version 1.0 (14-Mar-87)
Copyright (C) 1987 by Samuel H. Smith; All Rights Reserved.
You may copy and distribute this program freely, provided that:
1) No fee is charged for such copying and distribution, and
2) It is distributed ONLY in its original, unmodified state.
if you like this program, and find it of use, then your
contribution of $10 will be appreciated.
Please refer all inquiries to:
S. H. Smith
5119 N. 11th Ave 332
Phoenix, AZ 85013
This program allows you to use a number of C-like preprocessor
statements in a Turbo Pascal source file. It interprets the
statements and passes the processed text on to the Turbo compiler
for further processing.
The TSHELL program will load TURBO.COM into memory, install the
preprocessor shell, and enter the Turbo main menu. At this point,
Turbo Pascal can be used as always, except that the new
preprocessor commands can be used in any source file.
To start a Turbo Pascal session with the preprocessor shell, enter:
TSHELL
on the DOS command line.
A stand-alone (batch) version of the preprocessor is also
available. A single turbo source file can be preprocessed and
written to another file with this command:
TPP file.in >file.out
This command reads file.in, preprocesses it and writes the result
to file.out. This command is useful when you want to convert a
file that uses the TSHELL preprocessor back into a normal Turbo
Pascal source.
Overview
--------
The following C preprocessor directives are understood:
#define NAME STRING ;replace all instances of NAME with STRING
#undef NAME ;delete definition of NAME
#ifdef NAME ;compile only if NAME is defined
#ifndef NAME ;compile if NAME is not defined
#else ;compile otherwise
#endif ;resume normal compilation
#pragma NOEXPAND ;do not expand #defines in following lines
#pragma EXPAND ;resume #define expansion
#pragma LIST ;list preprocessed lines to screen
#pragma NOLIST ;stop listing
#include <file> ;include another file
The following special keywords are predefined:
SYSTEM_DATE ;the time/date when compile was started
LAST_UPDATE ;last modification time of current file
CURRENT_FILE ;name of current file
Note that keyword replacement takes place only when the keyword in
the source is surrounded by delimiters. A replacement will not
take place if the keyword is preceeded or followed by a number or a
letter. This preprocessor WILL make replacements within literals
and comments - beware!
Preprocessor commands
---------------------
Preprocessor commands must be alone on a line. Indentation is
allowed, but there cannot be a space between the '#' and the
command keyword.
#define NAME REPLACEMENT
This command arranges for any future instances of NAME to be
replaced by REPLACEMENT.
This command has two main uses:
1. to provide a simple macro replacement facility, and
2. to control conditional compilation (in conjunction with
the #ifdef and #ifndef commands).
#undef NAME
Remove any definition of NAME.
#ifdef NAME
If NAME has been defined with #define, the following code will
compile as normal. Otherwise, the following code will be
excluded from the compilation. Normal compilation resumes with
an #endif statement. For example:
#ifdef FAST_VIDEO
fast_display(x,y,'display data');
#else
gotoxy(x,y);
writeln(con,'display data');
#endif
#ifndef NAME
Like #ifdef but compiles code if the NAME has NOT been defined.
#else
Used with #ifdef to provide alternative code for cases where
the keyword is not defined.
#endif
Terminates a #ifdef block of code and resumes normal
compilation.
#pragma NOEXPAND
This command stops macro expansion. It is used in cases where
macro expansion is not desired. This also speeds up
compilation by eliminating the need to scan each line for
keywords.
#pragma EXPAND
This command resumes normal expansion of macros.
#pragma LIST
This command causes the source code to be listed to the screen
after macro expansion had taken place.
#pragma NOLIST
This command disables the source listing.
#include <file>
This command is passed on to turbo pascal as
{$I file}
where it is processed as usual. A future version of TSHELL
might implement nested include files through this command.
Predefined keywords
-------------------
SYSTEM_DATE
This keyword will be replaced with the time and date when the
compile was started. It has the form: dd-mmm-yy hh:mm:ss.
LAST_UPDATE
This keyword will be replaced with the last update date of the
current source file.
CURRENT_FILE
This keyword will be replaced with the full pathname of the
current source file.
Program requirements and limitations
------------------------------------
Version 1.0 of TSHELL works only with Turbo Pascal version 3.01a.
Future releases will work with more versions of Turbo. Note that
since TPP does not use TURBO.COM, it works with any version of
Turbo Pascal.
Memory used: About 50k of RAM, in addition to
that normally used by TURBO.COM.
Number of #define's: 100 different keywords can be
defined.
Maximum keyword length: Keywords can be up to 30 characters
in length. Keywords must follow
the same conventions as Turbo
Pascal identifiers.
Maximum replacement length: Replacement strings can be up to 70
characters long. Note that the
line length after macro expansion
cannot exceed 128 characters. This
limit is imposed by Turbo Pascal.
#ifdef nesting: #ifdef and #ifndef statements can
be nested up to 10 levels.
#include nesting: #include statements are still
handled by Turbo Pascal and cannot
be nested. A future version of
TSHELL will allow include file
nesting.